﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ProcessDosage.aspx.cs"
    Inherits="PerformanceReport.ProcessDosage" %>

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <base target="_self"></base>
    <title>流程用量统计</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <link href="CSS/reportCss.css" rel="stylesheet" type="text/css" />
    <script src="JS/jquery-1.4.4.min.js" type="text/javascript"></script>
    <script src="JavaScript/highcharts.js" type="text/javascript"></script>
    <script src="JavaScript/modules/exporting.js" type="text/javascript"></script>
    <script src="JS/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript" charset="utf-8"></script>
    <script type="text/javascript">
        var Json;
        var inc;
        var com;
        var can;
        var unc;

        var Completed;
        var INCIDENT;
        var UnFinished;
        var Cancelled;

        $(function () {
            var chart;
            //debugger;

            //选择业务单元后再查询             
            //var BusinessUnit = document.getElementById("drpBusinessUnit");
            //if (BusinessUnit.selectedIndex > 0) {
                GetJason();

                Completed = parseInt(Json[0].Completed);
                INCIDENT = parseInt(Json[0].INCIDENT);
                UnFinished = parseInt(Json[0].UnFinished);
                Cancelled = parseInt(Json[0].Cancelled);              
            //}
//            else {
//                Completed = 0;
//                INCIDENT = 0;
//                UnFinished = 0;
//                Cancelled = 0;
//            }

            //alert(Json[0].INCIDENT);
            //alert(Json[0].Completed);
            //alert(Json[0].UnFinished);
            //alert(Json[0].Cancelled);

            $(document).ready(function () {
                // GetJason();
                
                chart = new Highcharts.Chart({
                    chart: {
                        renderTo: 'container',
                        plotBackgroundColor: null,
                        plotBorderWidth: null,
                        plotShadow: false
                    },

                    title: {
                        //text: 'Browser market shares at a specific website, 2010'
                        text: ''
                    },
                    //tooltip: {
                    //formatter: function () {
                    //return '<b>' + this.point.name + '</b>: ' + this.percentage + ' %';
                    //}
                    //},
                    credits:       //去掉有效右下角的Highcharts.com的标志
                    {
                    href: '',
                    text: ''
                },
                plotOptions: {
                    pie: {
                        allowPointSelect: true,
                        cursor: 'pointer',
                        dataLabels: {
                            enabled: true,
                            color: '#000000',
                            connectorColor: '#000000',
                            formatter: function () {
                                //console.dir(this);
                                return '<b>' + this.point.name + '</b>: ' + this.y;
                                //return '<b>' + this.point.name + '</b>: ' + this.percentage + ' %';
                            }
                        }
                    }
                },

                series: [{
                    type: 'pie',
                    name: '有',
                    data: [
                    //['发起总数', parseInt(Json[0].INCIDENT)],
                    //['已完成', parseInt(Json[0].Completed)],
                        ['发起总数', INCIDENT],
                        ['已完成', Completed],
                        {
                            name: '已取消',
                            //y: parseInt(Json[0].Cancelled),
                            y: Cancelled,
                            sliced: true,
                            selected: true
                        },
                    // ['未完成', parseInt(Json[0].UnFinished)]
                        ['未完成', UnFinished]

                    //['INCIDENT', 20],
                    //['已完成', 30],
                    //{
                    //name: '已取消',
                    //y: 40,
                    //sliced: true,
                    //selected: true
                    //},
                    //['未完成', 120]

                             ]
                }]
            });
        });

    });
    function GetJason() {
        $.ajaxSetup({ async: false });
        var drpBu = $("#drpBusinessUnit").val();
        var VarStartTime = $("#txtStart").val();
        var VarEndTime = $("#txtEnd").val();
        //alert(drpBu);
        $.get("AjaxPage/GenerateDosageReports.ashx", { Para: drpBu, StartDate: VarStartTime, EndDate: VarEndTime }, function (data) {
            var arr = eval(data);
            var i = 0;
            Json = arr;                   
        })

    }
    </script>
    <script type="text/javascript">
        window.onload = function () {
            var oBtn = document.getElementById("btnSearch");

        }
        function checkInfo() {
            var oStart = document.getElementById("txtStart");
            var oEnd = document.getElementById("txtEnd");           
            var rdio = document.getElementById("Radio2").checked = "checked";  //设置数据报表为选中状态
        }

        //重置查询条件为初始状态
        function check() {
            var rdio = document.getElementById("Radio2").checked = "checked";   //设置数据报表为选中状态
            var ProcessName = document.getElementById("drpBusinessUnit");
            ProcessName.selectedIndex = 0;
            document.getElementById("txtStart").value = "";
            document.getElementById("txtEnd").value = "";
        }

    </script>
    <script type="text/javascript">
        function SetDiv(ee) {
            if (ee == "1") {
                $("#divList").css("display", "none");
                $("#container").css("display", "block");
                $("#divTotal").css("display", "none")
            } else {
                $("#divList").css("display", "block");
                $("#container").css("display", "none");
                $("#divTotal").css("display", "block")
            }
        }

    </script>
</head>
<body  style=" padding-left:15px">
    <form id="form1" runat="server">
    <div class="divHead" style=" padding-top:10px">
        <span style=" font-weight:bold; font-size:25px">
            流程用量统计 </span>
    </div>
    <div id="divCondition" runat="server" class="div_default_condition" style="padding-top: 10px">
        <fieldset>
            <legend style="font-size: 18px"><%--查询条件--%></legend>
            <table>
                <tr>
                    <td>
                        统计周期：&nbsp;<span style="color: Red">*</span>
                    </td>
                    <td>
                        开始时间
                        <asp:TextBox ID="txtStart" CssClass="input-query" onclick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy/MM/dd'})"
                            runat="server"></asp:TextBox>
                    </td>
                    <td>
                        结束时间
                        <asp:TextBox ID="txtEnd" CssClass="input-query" onclick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy/MM/dd'})"
                            runat="server"></asp:TextBox>
                    </td>
                    <td>
                        <span style=" color:Red">特别提示：由于流程历史数据过大，统计周期建议控制为三个月内。</span> 
                    </td>
                </tr>
                <tr>
                    <td>
                        流程名：&nbsp;<span style="color: Red">*</span>
                    </td>
                    <td style="padding-left: 53px;">
                        <asp:DropDownList ID="drpBusinessUnit" runat="server">
                         <%--   <asp:ListItem Value="" Selected="True">---请选择---</asp:ListItem>
                            <asp:ListItem Value="GW-">金风科技</asp:ListItem>
                            <asp:ListItem Value="FWDY-">天源科创</asp:ListItem>
                            <asp:ListItem Value="GWI-">金风国际</asp:ListItem>
                            <asp:ListItem Value="TR-">天润新能</asp:ListItem>--%>
                        </asp:DropDownList>
                    </td>
                      <td style="padding-left: 53px;">
                        <asp:Button ID="btnSearch" runat="server" CssClass="btn-primary" Text="查 询" OnClick="btnSearch_Click"
                            OnClientClick="return checkInfo()" />
                        <input id="btnReset" type="button" class="btn-primary" value="重 置" onclick="check()" />
                    </td>
                </tr>
                <tr>
                <td>
                    报表类型：
                </td>
                 <td>
                   <%-- <asp:RadioButtonList ID="rbReportType" runat="server" RepeatDirection="Horizontal"
                        TextAlign="Right">
                        <asp:ListItem Value="1" Text="图形报表" OnClick="SetDiv(this.value)"></asp:ListItem>
                        <asp:ListItem Value="2" Text="数据报表" OnClick="SetDiv(this.value)" Selected="True"></asp:ListItem>
                    </asp:RadioButtonList>--%>
                     <input id="Radio1" type="radio" name="CheckType" value="1" onclick="SetDiv(this.value)"/>图形报表
                     &nbsp;&nbsp;&nbsp;&nbsp;
                     <input id="Radio2" type="radio" name="CheckType" value="2" checked="checked" onclick="SetDiv(this.value)"/>数据报表
                    </td>
                  
                </tr>
            </table>
        </fieldset>
    </div>
    <div id="divList">
        <table width="99.5%" cellspacing="1" cellpadding="5" style="margin-left: 2px" border="1"
            bordercolor="#ccc">
            <tr>
                <th style="width: 5%">
                    序号
                </th>
                <th style="width: 30%">
                    流程名称
                </th>
                <th style="width: 8%">
                    发起量
                </th>
                <th style="width: 8%">
                    未完成
                </th>
                <th style="width: 8%">
                    已完成
                </th>
                <th style="width: 8%">
                    已取消
                </th>
                <th style="width: 8%">
                    完成率
                </th>
                <th style="width: 30%">
                    平均完成率（年度）
                </th>
            </tr>
            <tbody>
                <asp:Repeater ID="rpSource" runat="server">
                    <ItemTemplate>
                        <tr onmouseover="currentcolor=this.style.backgroundColor;this.style.backgroundColor='#F3F3F3';"
                            onmouseout="this.style.backgroundColor=currentcolor;" style='background-color: <%# (Container.ItemIndex + 1)%2==0?"#F9F9F9":"" %>;
                            cursor: pointer;'>
                            <td>
                                <%#Container.ItemIndex+1 %>
                            </td>
                            <td>
                                <%#Eval("ProcessName")%>
                            </td>
                            <td>
                                <%#Eval("INCIDENT")%>
                            </td>
                            <td>
                                <%#Eval("UnFinished")%>
                            </td>
                            <td>
                                <%#Eval("Completed")%>
                            </td>
                            <td>
                                <%#Eval("Cancelled")%>
                            </td>
                            <td>
                                <%#GetCompletionRate(Eval("Completed").ToString(), Eval("INCIDENT").ToString())%>
                            </td>
                            <td>
                                <%#GetAvgCompletionRate(Eval("Completed").ToString(), Eval("INCIDENT").ToString(),Eval("Cancelled").ToString())%>
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
            </tbody>
            <tr>
                <td colspan="19" style="text-align: left; padding: 5px;">
                    <webdiyer:AspNetPager ID="AspNetPager1" runat="server" CustomInfoHTML="Count %RecordCount%"
                        HorizontalAlign="left" Width="100%" CssClass="aspNetPager" OnPageChanged="AspNetPager1_PageChanged"
                        PageSize="10" AlwaysShow="true" SubmitButtonStyle="display:none" InputBoxStyle="display:none"
                        NextPageText="下一页" FirstPageText="首页" LastPageText="末页" PrevPageText="上一页">
                    </webdiyer:AspNetPager>
                </td>
            </tr>
        </table>
    </div>
    <div id="divTotal">
        <h5 style="color: Red">
            <asp:Label ID="lbTotal" runat="server" /></h5>
    </div>
    <div id="container" style="min-width: 400px; height: 400px; margin: 0 auto">
    </div>
    </form>
</body>
</html>
